/**
 * 设置token
 * @param {Object} token
 */
export function login(token, domains){
	console.log(domains)
	try {
	    uni.setStorageSync('access_token_w', token)
	    uni.setStorageSync('domains_w', domains)
	} catch (e) {}
}

/**
 * 退出登录
 */
export function logout(){
	try {
		uni.removeStorageSync('token')
	} catch (e) {}
}

/**
 * 获取token
 */
export function getToken(){
	try {
	    let access_token = uni.getStorageSync('token');
	    if (access_token) {
	        return access_token
	    }
	} catch (e) {}
	return ''
}

export function getDomains(){
	try {
	    let domains = uni.getStorageSync('domains_w');
	    if (domains) {
	        return domains
	    }
	} catch (e) {}
	return ''
}

/**
 * 是否登录
 */
export function checkLogin(jump = true){
	let access_token = getToken()
	if(access_token) return true
	if(jump){
		uni.$u.route('/pagesA/login/login')
	}
	return false
}